/*
 * File:DefaultCommandInvoker.java
 * Type:net.wangds.common.command.DefaultCommandInvoker
 */

package net.wangds.common.command;

import net.wangds.common.GeneralParentObject;

/**
 * 默认命令调用者.
 * <p>
 * <h1>修改列表:</h1>
 * <ol>
 * <li>checkstyle, by wangds@gmail.com, 2016-01-16 下午18:13</li>
 * <li>初始版本, by wangds@gmail.com, 2013-11-7 上午10:50:26</li>
 * </ol>
 * </p>
 * 
 * @author wangds@gmail.com
 * @version 0.1.2
 * @since 0.1
 */
public class DefaultCommandInvoker<R extends CommandReceiver, C extends Command<R>>
    extends GeneralParentObject
    implements Invoker<R, C> {

  @Override
  public C buildCommand(final R receiver, final C command) {
    if (receiver != null && command != null) {
      command.setReceiver(receiver);
    }
    return command;
  }

  @Override
  public void invoke(final C command) throws Exception {
    if (command != null) {
      command.process();
    }
  }

}
